<?php
	session_start();
	require_once("../db_connect.php");
	require_once("filter.php");

	//サブカテゴリ一覧表示
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet"  href="../../css/admin.css" type="text/css" />

<title>管理者画面</title>
</head>
        <body>
		<div id="topmain" >
			<div id="topwaku">カテゴリ管理</div>
				<div id="enpty"></div>
					<div id="topimage"><a href="manager_create.php" >管理者登録</a></div>
					<div id="topimage"><a href="ManagerLogout.php" >ログアウト</a></div>
		</div>
		<div id="leftmain">
			<div id="leftmainwaku">
				<div id="koumoku"><a href="../../manager_index.php" >・管理トップページ</a></div>
				<div id="koumoku"><a href="manage_sub_category_insert.php" >・新規<br/>サブカテゴリ登録</a></div>
				<div id="koumoku"><a href="manage_main_category.php" >・戻る</a></div>
			</div>
		</div>
		<div id="centerup">
		<div id="centerwaku">
			<div id="centertitle">
				<div id="centerchara">メインカテゴリ詳細</div>
			</div>
			</div>
			<div id="centerinsert">
			<div id="centerinsert2">
<table border="1" >
<tr>
<th>サブカテゴリID</th>
<th>サブカテゴリ名</th>
<th>削除</th>
</tr>
<?php

if(isset($_GET['main_category_detail_id'])){
	$_SESSION['main_category_id']  = htmlspecialchars($_GET['main_category_detail_id'],ENT_QUOTES,"UTF-8");
}

$sql = "SELECT sub_category_id,sub_category_name
		FROM sub_category
		WHERE main_category_id = ?";

$stmt = $db->prepare($sql);

$data = array($_SESSION['main_category_id']);

$res =& $db->execute($stmt,$data);

	if (PEAR::isError($res)) {			//SQLの実行に失敗すればここでエラー文を出力
		die($res->getMessage());
	}

	while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) {
		echo "<tr>";
		echo "<th>".$row['sub_category_id']."</th>";
		echo "<th>".$row['sub_category_name']."</th>";
		echo "<th><a href='ManageSubCategoryDelete.php?sub_category_delete_id=".$row['sub_category_id']."' >削除</a></th>";
		echo "</tr>";
	}
?>
</table>
</div>
</div>
</div>
</body>
</html>